import os from 'os'

const ARCH_ARM64 = 'arm64'
const ARCH_X64 = 'x64'

const PLATFORM_WIN = 'win'
const PLATFORM_DARWIN = 'darwin'
const PLATFORM_LINUX = 'linux'

function getArch(): string {
    const arch: string = os.arch()
    switch (arch) {
        case 'amd64':
            return ARCH_X64
        case 'aarch64':
            return ARCH_ARM64
        default:
            return arch
    }
}

function getPlatform(): string {
    const platform: string = os.platform()
    switch (platform) {
        case 'win32':
            return PLATFORM_WIN
        case 'darwin':
            return PLATFORM_DARWIN
        case 'linux':
            return PLATFORM_LINUX
        default:
            return platform
    }
}

export default {
    ARCH_ARM64,
    ARCH_X64,
    PLATFORM_DARWIN,
    PLATFORM_LINUX,
    PLATFORM_WIN,
    getArch,
    getPlatform
}
